package com.runtime.hongyunuser.mapper;

import com.runtime.hongyunuser.bean.Shoppingcarts;
import com.runtime.hongyunuser.bean.vo.CartProductVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ShoppingcartsMapper {

    // 根据用户ID和商品ID查找购物车项
    Shoppingcarts findByUserIdAndProductId(@Param("userId") Long userId, @Param("productId") Long productId);

    // 添加商品到购物车
    void save(Shoppingcarts shoppingcart);

    // 更新购物车项
    void update(Shoppingcarts shoppingcart);

    // 删除购物车项
    void delete(@Param("userId") Long userId, @Param("productId") Long productId);

    // 获取用户的所有购物车项
    List<Shoppingcarts> getCartItems(Long userId);

    List<CartProductVO> listCartProductsByUserId(Long userId);

    // 清空用户购物车
    void clearCart(Long userId);

    Shoppingcarts findByCartId(Long cartId);

    int removeBatchFromCart(@Param("userId") Long userId, @Param("cartIds") List<Long> cartIds);
}